package com.notices.controller;

import com.notices.pojo.Notices;
import com.notices.service.INoticesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/notices")
public class NoticesController {
    @Autowired
    private INoticesService service;
    @GetMapping
    public List<Notices> list(){
        return service.list();
    }
    @GetMapping("/{id}")
    public Notices getInfo(@PathVariable Integer id) {
            return service.getById(id);
    }
    @PostMapping
    public Integer add(@RequestBody Notices notices){
        int rlt= service.add(notices);
        return rlt;
    }
    @PutMapping
    public Integer update(@RequestBody Notices notices){
        return service.update(notices);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return service.delete(id);
    }
}
